package GoFPatterns.kt.demo.service.impl;

import GoFPatterns.kt.demo.dao.NewsDao;
import GoFPatterns.kt.demo.entity.News;
import GoFPatterns.kt.demo.service.NewsService;

public class NewsServiceImpl implements NewsService {
//    private NewsDao dao = SimpleDaoFactory.getInstance();
    //根据依赖倒置原则，使用setter方法传递依赖关系
    private NewsDao dao;
    public void setDao(NewsDao dao){
        this.dao = dao;
    }
    @Override
    public void addNews(News news) {
        //调用NewsDao的方法保存新闻信息
        dao.save(news);
    }
}
